package com.learn.use.myreconsituteproject.register.presenter;

import android.content.Context;

import com.learn.use.myreconsituteproject.mvp.BasePresenter;
import com.learn.use.myreconsituteproject.mvp.codebean.CodeBean;
import com.learn.use.myreconsituteproject.register.bean.RegisterNextBean;
import com.learn.use.myreconsituteproject.register.model.RegisterModel;
import com.learn.use.myreconsituteproject.register.view.RegisterView;

/**
 * Created by 聪明一只哈 on 2018/9/12.
 * Time: 2018/9/12  11:53
 */
public class RgDataPresenter<T extends RegisterView> extends BasePresenter<T> implements RegisterPresenter{


    private final RegisterModel registerModel;

    public RgDataPresenter() {
        registerModel = new RegisterModel();
    }

    @Override
    public void beforeRequest(int requestTag) {
        mVIewRef.get().showProgress();

    }
    @Override
    public void requestComplete(int requestTag) {
        mVIewRef.get().dissProgress();

    }

    @Override
    public void codeError(String e, int requestTag) {
        mVIewRef.get().dissProgress();
        mVIewRef.get().getCodeError(e);


    }
    @Override
    public void codeSuccess(Object callBack, int requestTag) {
        mVIewRef.get().dissProgress();
        mVIewRef.get().getCodeData((CodeBean)callBack);

    }


    /**
     * 获取验证码
     * @param ase
     * @param num
     */
    public void getRecongCode(String ase, String num){
        registerModel.getRegisterData(ase,num,this);
    }

    //========================================================
    @Override
    public void registedSuccess(Object callBack) {
        mVIewRef.get().dissProgress();
        mVIewRef.get().RegisteDatasSuccess((RegisterNextBean)callBack);

    }

    @Override
    public void registeredFiled(String message) {
        mVIewRef.get().dissProgress();
        mVIewRef.get().RegisteDatasFiled(message);

    }

    /**
     * 注册账号
     * @param context
     * @param num
     * @param pass
     * @param code
     * @param aes
     */
    public void getRegisteredData(Context context, String num, String pass, String code, String aes){
        registerModel.RegisterDataCount(context,num,pass,code,aes,this);
    }



}
